package com.ytjj.qmyx.admin.controller.bigdata;

import com.ytjj.common.api.CommonResult;
import com.ytjj.common.model.ExposureNumResponse;
import com.ytjj.qmyx.admin.service.bigdata.AdsExposeService;
import com.ytjj.qmyx.users.client.BigdataClient;
import com.ytjj.qmyx.users.model.bigdata.AdsExpose;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/adsExpose")
@Slf4j
public class AdxExposeController {
    @Autowired
    private AdsExposeService adsExposeService;
    @Autowired
    private BigdataClient bigdataClient;

    @GetMapping("/sumDataByUserId")
    public CommonResult sumDataByUserId(@RequestParam Integer userId) {
        return bigdataClient.sumDataByUserId(userId);
    }

    @GetMapping("/sumExposureByDynamicId")
    public ExposureNumResponse sumExposureByDynamicId(@RequestParam Integer dynamicId) {
        return bigdataClient.sumExposureByDynamicId(dynamicId);
    }

    @GetMapping("/scheduleTask")
    public void scheduleTask() {
        List<AdsExpose> list = bigdataClient.scheduleTask();
        adsExposeService.scheduleTask(list);
    }

}
